var profilecontroller = {

		loadChart : function(w1, w2, w3, w4, w5, w6) {
			var wn = localStorage.getItem("week_num");
            var dn = localStorage.getItem("day_num");
            var p = localStorage.getItem("total_points");
            var w1 = 0;
            var w2 = 0;
            var w3 = 0;
            var w4 = 0;
            var w5 = 0;
            var w6 = 0;
            if (wn == 1) {
            	w2 = w3 = w4 = w5 = w6 = 0;
            	if (dn == 1) {
            		w1 = 0;
            	} else if (dn == 2) {
            		w1 = 33;
            	} else if (dn == 3) {
            		w1 = 66;
            	}
            } else if (wn == 2) {
        		w1 = 100;
        		w3 = w4 = w5 = w6 = 0;
            	if (dn == 1) {
            		w2 = 0;
            	} else if (dn == 2) {
            		w2 = 33;
            	} else if (dn == 3) {
            		w2 = 66;
            	}
            } else if (wn == 3) {
            	w1 = w2 = 100;
        		w4 = w5 = w6 = 0;
            	if (dn == 1) {
            		w3 = 0;
            	} else if (dn == 2) {
            		w3 = 33;
            	} else if (dn == 3) {
            		w3 = 66;
            	}
            } else if (wn == 4) {
            	w1 = w2 = w3 = 100;
        		w5 = w6 = 0;
            	if (dn == 1) {
            		w4 = 0;
            	} else if (dn == 2) {
            		w4 = 33;
            	} else if (dn == 3) {
            		w4 = 66;
            	}
            } else if (wn == 5) {
            	w1 = w2 = w3 = w4 = 100;
        		w6 = 0;
            	if (dn == 1) {
            		w5 = 0;
            	} else if (dn == 2) {
            		w5 = 33;
            	} else if (dn == 3) {
            		w5 = 66;
            	}
            } else if (wn == 6) {
            	w1 = w2 = w3 = w4 = w5 = 100;
            	if (dn == 1) {
            		w6 = 0;
            	} else if (dn == 2) {
            		w6 = 33;
            	} else if (dn == 3) {
            		w6 = 66;
            	}
            } 
			$('#barGaugeContainer').dxBarGauge({
				geometry: {
		            startAngle: 225,
		            endAngle: 225
		        },
		        title: {
		    		text: 'Progress (%)',
		    		font: { 
		    			weight: 900,
			        	size: 22 
			        }
		    	},
		        startValue: 0,
	            endValue: 100,
	            values: [w1, w2, w3, w4, w5, w6]
			});
	},
		
       loadProfileContent: function(){
            // Only on first load
            if(localStorage.getItem("total_points") === null){
                var result = localStorage.getItem('initialtest_result');
                CategoryBL.matchInitialTestToCategory(result);
            }
            profilecontroller.getPhoto('#pushups_profile_img');
            $.mobile.activePage.find('#lblProfileUsername').text(profilecontroller.readUserEmail());
            $.mobile.activePage.find('#lblStats').text(
             " You are in week "+localStorage.getItem("week_num")+
             " and day "+localStorage.getItem("day_num") + ".");
            $.mobile.activePage.find('#points').text(localStorage.getItem("total_points"));
       },

       readUserEmail: function(){
            return localStorage.getItem("username");
       },

       readUsername: function(){
            return localStorage.getItem("user_email");
       },

       getPhoto : function(canvas_id){
            var c1 =  $.mobile.activePage.find(canvas_id);
            var ctx1 = c1[0].getContext("2d");
            var dataURL = localStorage.getItem('pushups_profile_img');
            var img = new Image;
            img.onload = function(){
                ctx1.drawImage(img, 0, 0);
            };
          	img.src = dataURL;
       }
};